mob
	player
		icon = 'graphics/ships.dmi'
		pixel_step = 1
		width = 16
		height = 16
		iconx = 9
		icony = 9
		absx = 48
		absy = 496
		density = 1

		/*
		// NEW
		*/
		Login()
			..()
			client.eye = locate(12,5,1)
			//src.PixMove(128,160)
			var/x = (rand(VIEW_X) * 32) + 64
			var/y = rand(VIEW_Y) * 32
			src.PixMove(x,y)
			// Cheaters
			src.move = rand(-1,1)
			src.thrusters = rand(-1,1)
		/*
		// MOVEMENT
		*/
		var
			move = 0  // -1 for down 1 for up 0 for none
			thrusters = 0 // -1 to go left 1 to right, 0 for none
			delayx = 0

		verb
			move_up()
				set hidden = 1
				set name = "move_up"
				set instant = 1

				if(src.move <  1) src.move++
				icon_state = "[move]"

			move_down()
				set hidden = 1
				set name = "move_down"
				set instant = 1

				if(src.move > -1) src.move--
				icon_state = "[move]"

			move_left()
				set hidden = 1
				set name = "move_left"
				set instant = 1
				if(src.thrusters > -2) src.thrusters--

			move_right()
				set hidden = 1
				set name = "move_right"
				set instant = 1
				if(src.move < 2) src.thrusters++

		PixMove(X,Y,Z,Dir)
			.=..()
			if(. && client)
				var/y_p_min = VIEW_Y * 32
				var/y_p_max = (world.maxy - VIEW_Y - 1) * 32
				if(Y > y_p_min && Y < y_p_max)
					client.pixel_y = pixel_y
				else
					client.pixel_y = 0

		Loop()
			if(src.move != 0 || src.thrusters != 0)
				var/ymove = src.move
				if(speedup > 0) ymove *= 2 * speedup

				var/Y = absy + ymove
				var/X = absx

				if(delayx >= 3)
					X += thrusters
					delayx = 0
				delayx ++

				if(Y > 1 && Y < 319)
					PixMove(absx,Y)

				// Out of bound corrections
				if(Y < 2)
					Y = (world.maxy * 32) - 1

				if(Y > (world.maxy * 32) - 1)
					Y = 2

				if(X < 33)
					//thrusters = 0
					X = ((world.maxx - 2) * 32) - 1

				if(X >  ((world.maxx - 2) * 32) - 1)
					X = 33

				PixMove(X,Y)
			..()



		/*
		// HIT DECTION
		*/
		PixBump(atom/A, BumpDir)
			// If the player gets hit
			if(istype(A, /mob/asteroids))
				hit()
				del(A)
				return 1
			if(istype(A, /mob/fuel))
				fuel()
				del(A)
				return 1
		var
			life = 10

		proc
			hit()
				life --
				src.life_update(10,life)
				if(life < 1) game_over()

			life_update(mhp = 100,chp = 100)
				var/v = 0
				if(mhp >= chp) v = (chp / mhp) * 100
				winset(src, "game.bar_life", "value=[v]")

		/*
		// FUEL
		*/
		var
			max_fuel 	= 10000
			fuel 		= 10000

			fuel_got = 0

		proc
			fuel()
				fuel += rand(max_fuel/2,max_fuel)
				if(fuel > max_fuel) fuel = max_fuel
				fuel_update(max_fuel,fuel)
				fuel_got++

			fuel_update(mfuel = 100,cfuel = 100)
				var/v = 0
				if(mfuel >= cfuel) v = (cfuel / mfuel) * 100
				winset(src, "game.bar_fuel", "value=[v]")

		Loop()
			..()
			if(playing > 0)
				fuel--
				fuel_update(max_fuel,fuel)
				if(fuel < 1) game_over()

		/*
		// GAME OVER
		*/
		Logout()
			..()
			stop_all = 1
			//set_highscore()

		proc
			game_over()
				stop_all = 1
				highscore_medals()
				world.Reboot()


		/*
		// SCORE
		*/
		var
			score = 1
			time = 1

		Loop()
			..()
			if(playing > 0)
				time ++
				score = round(time / 5)
				update_score()

		proc
			update_score()
				winset(src, "game.label_score", "text=[score]")
